/*
 *
 *      Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the pig4cloud.com developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: lengleng (wangiegie@gmail.com)
 *
 */

package com.pig4cloud.pigx.admin.service.impl;

import cn.hutool.core.lang.Assert;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.dto.StorageCapacityDto;
import com.pig4cloud.pigx.admin.api.entity.OverallStorageCapacity;
import com.pig4cloud.pigx.admin.mapper.OverallStorageCapacityMapper;
import com.pig4cloud.pigx.admin.service.OverallStorageCapacityService;
import com.pig4cloud.pigx.admin.utils.JsonUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * <p>
 * 四全库容数据 服务实现类
 * </p>
 *
 * @author lengleng
 * @since 2018-01-20
 */
@Service
@AllArgsConstructor
@Slf4j
public class OverallStorageCapacityServiceImpl extends ServiceImpl<OverallStorageCapacityMapper, OverallStorageCapacity> implements OverallStorageCapacityService {


    private final OverallStorageCapacityMapper mapper;


    /**
     *
     * @param res
     * @return List<OverallStorageCapacity>
     * @author lfx
     * @date 2024/8/10 15:09
     * @Desc 查询库容曲线列表
     **/
    @Override
    public List<OverallStorageCapacity> selectList(StorageCapacityDto res) {
        log.info("查询库容曲线列表入参：{}", JsonUtil.obj2String(res));
        Assert.notNull(res, "查询库容曲线列表入参不能为空");
        List<OverallStorageCapacity> capacityList = mapper.selectList(Wrappers.lambdaQuery(OverallStorageCapacity.class)
                .eq(StringUtils.isNotEmpty(res.getReservoirId()), OverallStorageCapacity::getReservoirId, res.getReservoirId())
                .like(StringUtils.isNotEmpty(res.getTime()), OverallStorageCapacity::getTime, res.getTime())
                .eq(ObjectUtils.isNotEmpty(res.getWaterLevel()), OverallStorageCapacity::getWaterLevel, res.getWaterLevel()));
        return capacityList;
    }
}
